//index.js
//获取应用实例
const app = getApp()
import req from '../../utils/Request.js';
import appReq from '../../utils/AppRequest.js';

Page({
  data: {
    userInfo: {},
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    type: "nothing",
  },
  onLoad: function () {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo
      })
    } else if (this.data.canIUse) {
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo
          })
        }
      })
    }
  },
  callMe:function() {
    wx.makePhoneCall({
      phoneNumber: '13370555874',
    })
  },
  about: function () {
    this.setData({
      type: "about"
    })
  },
  back: function () {
    this.setData({
      type: "nothing"
    })
  },
  announcement: function () {
    this.setData({
      type: "announcement"
    })
  },
  goAttention: function() {
    wx.navigateTo({
      url: '../attention/index'
    })
  }
})